<% layout('/layouts/default.html', {title: '出入库单管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('出入库单管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('st:stInventoryBill:edit')){ %>
					<a href="${ctx}/st/stInventoryBill/outBill" class="btn btn-default btnTool" title="${text('新增出入库单')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
					<a href="${ctx}/st/stInventoryBill/saleOutForm" class="btn btn-default btnTool" title="${text('销售出库')}"><i class="fa fa-plus"></i> ${text('销售出库')}</a>
					<a href="${ctx}/st/stInventoryBill/purchaseIn" class="btn btn-default btnTool" title="${text('采购入库')}"><i class="fa fa-plus"></i> ${text('采购入库')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${stInventoryBill}" action="${ctx}/st/stInventoryBill/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('单据号')}：</label>
					<div class="control-inline">
						<#form:input path="billNo" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('单据日期')}：</label>
					<div class="control-inline">
						<#form:input path="billDate" readonly="true" maxlength="20" class="form-control laydate width-datetime"
							dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('单据类别')}：</label>
					<div class="control-inline width-120">
						<#form:select path="billType" dictType="st_stock_in_bill_type" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('入账日期')}：</label>
					<div class="control-inline">
						<#form:input path="tallyDate" readonly="true" maxlength="20" class="form-control laydate width-datetime"
							dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('条码扫描')}：</label>
					<div class="control-inline">
						<#form:input path="barCode" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('源单')}：</label>
					<div class="control-inline">
						<#form:input path="primaryBillNo" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('出库或入库')}：</label>
					<div class="control-inline width-120">
						<#form:select path="inOrOut" dictType="st_inventory_bill_type" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('部门编码')}：</label>
					<div class="control-inline">
						<#form:input path="deptCode" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('部门')}：</label>
					<div class="control-inline">
						<#form:input path="deptName" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('审批状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="approveState" dictType="st_approve_state" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('审批人编码')}：</label>
					<div class="control-inline">
						<#form:input path="approveManCode" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('审批人')}：</label>
					<div class="control-inline">
						<#form:input path="approveManName" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('备注信息')}：</label>
					<div class="control-inline">
						<#form:input path="remarks" maxlength="500" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("单据号")}', name:'billNo', index:'a.bill_no', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){

			var url="form";
			var half=1;
			switch(row.inOrOut){

				case 33:
					url = "saleOutForm";
					break;
				case 31://产品
					half = 2;
					url = "completeProductForm";
					break;
				case 32://半成品
					half = 1;
					url = "completeProductForm";
					break;
				case 1://采购入库
					url = "purchaseIn";
					break;
				case 12:
				case 11:
					url = "inventoryStatus";
					break;
			}

			return '<a href="${ctx}/st/stInventoryBill/'+url+'?id='+row.id+"&half="+half+'" class="btnList" data-title="${text("编辑出入库单")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("单据日期")}', name:'billDate', index:'a.bill_date', width:150, align:"center"},
		{header:'${text("单据类别")}', name:'billType', index:'a.bill_type', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_stock_in_bill_type')}, val, '${text("未知")}', true);
		}},
		{header:'${text("入账日期")}', name:'tallyDate', index:'a.tally_date', width:150, align:"center"},
		{header:'${text("条码扫描")}', name:'barCode', index:'a.bar_code', width:150, align:"left"},
		{header:'${text("源单")}', name:'primaryBillNo', index:'a.primary_bill_no', width:150, align:"left"},
		{header:'${text("出库或入库")}', name:'inOrOut', index:'a.in_or_out', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_inventory_bill_type')}, val, '${text("未知")}', true);
		}},
		{header:'${text("部门编码")}', name:'deptCode', index:'a.dept_code', width:150, align:"left"},
		{header:'${text("部门")}', name:'deptName', index:'a.dept_name', width:150, align:"left"},
		{header:'${text("审批状态")}', name:'approveState', index:'a.approve_state', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('st_approve_state')}, val, '${text("未知")}', true);
		}},
		{header:'${text("审批人编码")}', name:'approveManCode', index:'a.approve_man_code', width:150, align:"left"},
		{header:'${text("审批人")}', name:'approveManName', index:'a.approve_man_name', width:150, align:"left"},
		{header:'${text("更新时间")}', name:'updateDate', index:'a.update_date', width:150, align:"center"},
		{header:'${text("备注信息")}', name:'remarks', index:'a.remarks', width:150, align:"left"},
		{header:'${text("操作")}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('st:stInventoryBill:edit')){ %>
				//actions.push('<a href="${ctx}/st/stInventoryBill/form?id='+row.id+'" class="btnList" title="${text("编辑出入库单")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/st/stInventoryBill/delete?id='+row.id+'" class="btnList" title="${text("删除出入库单")}" data-confirm="${text("确认要删除该出入库单吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>